
const setLocalStorageItem = (data, dataName) => {
  const cartListString = JSON.stringify(data)
  localStorage[dataName] = cartListString
}

const getLocalStorageItem = (dataName) => {
  return JSON.parse(localStorage[dataName])
}

const setLocalStorageState = (state) => {
  const { cartList } = state
  const cartListString = JSON.stringify(cartList)
  localStorage.cartList = cartListString
}

const getLocalStorageItemState = () => {
  return localStorage.cartList !== undefined ? JSON.parse(localStorage.cartList) : {}
}
export { setLocalStorageItem, getLocalStorageItem, setLocalStorageState, getLocalStorageItemState }
